//
//  BSSBillDetailsLsitTableViewCell.m
//  BSSMarket
//
//  Created by 传铎 on 2020/9/25.
//  Copyright © 2020 BSS. All rights reserved.
//

#import "BSSBillDetailsLsitTableViewCell.h"

@implementation BSSBillDetailsLsitTableViewCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style
              reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.accessoryType = UITableViewCellAccessoryNone;
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.backgroundColor = [UIColor clearColor];
        self.contentView.backgroundColor = [UIColor clearColor];
        [self createUI];
    }
    return self;
}
- (void)createUI{
    _typeImageV = [[UIImageView alloc]init];
    [self.contentView addSubview:_typeImageV];
    
    [_typeImageV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(12);
        make.top.mas_equalTo(15);
        make.width.mas_equalTo(14);
        make.height.mas_equalTo(14);
    }];
    _amountLabel = [[UILabel alloc]init];
    [self.contentView addSubview:_amountLabel];
    _amountLabel.textAlignment = NSTextAlignmentRight;
    _amountLabel.textColor = colorCode(@"#7A7881");
    _amountLabel.font = fontCount(12);
    
    [_amountLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(12);
        make.right.mas_equalTo(-12);
        
    }];
    
    _titleLabel = [[UILabel alloc]init];
    [self.contentView addSubview:_titleLabel];
//    _titleLabel.numberOfLines = 3;
    _titleLabel.textColor = colorCode(@"#333333");
    _titleLabel.font = fontCount(15);
    
    [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(_amountLabel.mas_centerY);
        make.left.mas_equalTo(_typeImageV.mas_right).offset(5);
        make.right.mas_equalTo(_amountLabel.mas_left).offset(-3);
    }];
    
    [_amountLabel setContentCompressionResistancePriority:UILayoutPriorityDefaultHigh forAxis:UILayoutConstraintAxisHorizontal];
    [_titleLabel setContentCompressionResistancePriority:UILayoutPriorityDefaultLow forAxis:UILayoutConstraintAxisHorizontal];
    
    
    _timeLabel = [[UILabel alloc]init];
    [self.contentView addSubview:_timeLabel];
    _timeLabel.textColor = colorCode(@"#999999");
    _timeLabel.font = fontCount(13);
    
    [_timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(_typeImageV.mas_right).offset(5);
        make.top.mas_equalTo(_titleLabel.mas_bottom).offset(10);
        make.bottom.mas_equalTo(-19);
    }];
    
    _typeLabel = [[UILabel alloc]init];
    [self.contentView addSubview:_typeLabel];
    _typeLabel.textColor = colorCode(@"#666666");
    _typeLabel.font = fontCount(13);
    
    [_typeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-12);
        make.centerY.mas_equalTo(_timeLabel.mas_centerY);
    }];
    
    
    
    
}
- (NSString *)timeConversionC:(NSString *)time{
    if (IsEmpty(time)) {
        return @"";
    }
    NSString *str;
    if (time.length >=10) {
        str = [NSString stringWithFormat:@"%@-%@-%@ %@:%@",[time substringWithRange:NSMakeRange(0, 4)],[time substringWithRange:NSMakeRange(4, 2)],[time substringWithRange:NSMakeRange(6, 2)],[time substringWithRange:NSMakeRange(8, 2)],[time substringWithRange:NSMakeRange(10, 2)]];
        return str;
    }else{
        return time;
    }
}
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
